// pages/home/xiang/xiang.js
let WxParse = require('../../../wxParse/wxParse.js');
const http = require('../js/ajax.js')
const api = require('../js/api.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    shang: [],
    swiperCurrent: 0,
    indicatorDots: true,
    autoplay: true,
    interval: 3000,
    duration: 800,
    circular: true,
  },
  //点击图片
  swipclick: function (e) {
    //console.log(this.data.swiperCurrent);
    wx.switchTab({
      url: this.data.links[this.data.swiperCurrent]
    })
  },
  //轮播图的切换事件
  swiperChange: function (e) {
    this.setData({
      swiperCurrent: e.detail.current
    })
  },
  //点击指示点切换
  chuangEvent: function (e) {
    this.setData({
      swiperCurrent: e.currentTarget.id
    })
  },
  //点击图片触发事件
  swipclick: function (e) {
    //console.log(this.data.swiperCurrent);
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.getStorageSync("spxq")
    var spxq = wx.getStorageSync("spxq");
    //console.log("商品详情",spxq)
    let num = options.id
    //this.shang(num)
    //console.log('111',num)
    this.setData({
      shang: spxq[num]
    })
    //console.log("sahng",this.data.shang)
    let thit = this
    let article = this.data.shang.goodsDetail;
    WxParse.wxParse('article', 'html', article, thit);
  },
  //商品是否收藏
  cang() {
    let data = {
      "customerId": 589,
      "memberId": 589,
      "shopId": 18,
      "storeId": 56200,
      "goodsName": this.data.shang.goodsName,
      "goodsId": this.data.shang.goodsId
    }
    http(api.spsc, "data", data, "POST").then(res => {
      console.log("成功", res)
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.cang()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})